Skip to content

[nanvix] fix(libcxx): add Nanvix platform support (clock + rune table)#36

Merged
ppenna merged 1 commit into
nanvix/v21.0.0from
bugfix-stage1-libcxx-nanvix-platform
Jun 30, 2026
Merged

[nanvix] fix(libcxx): add Nanvix platform support (clock + rune table)#36
ppenna merged 1 commit into
nanvix/v21.0.0from
bugfix-stage1-libcxx-nanvix-platform

Conversation

@ppenna

@ppenna ppenna commented Jun 30, 2026

Copy link
Copy Markdown

Problem

The #35 merge cleared the wide-character blocker; the libc++ build then failed with two platform-detection errors:

chrono.cpp: error: "Monotonic clock not implemented on this platform"
__locale:   error: unknown rune table for this platform -- do you mean to define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE?

Both are because libc++ doesn't recognize Nanvix as a platform.

Fix (add Nanvix platform support to libc++)

  • chrono.cpp — Nanvix provides clock_gettime() + CLOCK_MONOTONIC (declared in <time.h>, defined in libc.a), so add __nanvix__ to the targets that define _LIBCPP_HAS_CLOCK_GETTIME (alongside OpenBSD/hurd). steady_clock then uses clock_gettime(CLOCK_MONOTONIC). (The libc's <unistd.h> doesn't advertise _POSIX_TIMERS, which is why the generic detection missed it — fixing that upstream would also work.)
  • __config + __cxx03/__config — Nanvix has no platform ctype "rune table", so use libc++'s built-in default table by adding __nanvix__ to the _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE list (as NuttX/Fuchsia/wasi do). The locale base API then falls through to the BSD POSIX fallbacks.

This keeps localization enabled (<locale>, <iostream>, <regex>) rather than disabling it — consistent with the fork's existing __nanvix__ handling already present in __config.

Caveat

Iterative stage-1 bring-up. These clear the two detection errors; subsequent libc++/libc++abi compile or link issues may surface next. Validated on merge (PR CI verifies stage 0 only).

Stage-1 build of libc++ failed with two platform-detection errors:

  chrono.cpp: error: "Monotonic clock not implemented on this platform"
  __locale:   error: unknown rune table for this platform -- do you mean
              to define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE?

Both are because libc++ does not recognize Nanvix. Add it:

- chrono.cpp: Nanvix provides clock_gettime() and CLOCK_MONOTONIC (declared in
  <time.h>, defined in libc.a), so add __nanvix__ to the targets that define
  _LIBCPP_HAS_CLOCK_GETTIME (alongside OpenBSD/hurd); steady_clock then uses
  clock_gettime(CLOCK_MONOTONIC). The libc's <unistd.h> does not advertise
  _POSIX_TIMERS, which is why the generic detection missed it.

- __config + __cxx03/__config: Nanvix has no platform ctype "rune table", so
  use libc++'s built-in default table by adding __nanvix__ to the
  _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE list (as NuttX/Fuchsia/wasi do). The
  locale base API falls through to the BSD POSIX fallbacks, keeping
  localization (<locale>, <iostream>, <regex>) enabled.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ppenna ppenna merged commit 1d06041 into nanvix/v21.0.0 Jun 30, 2026
1 check passed
@ppenna ppenna deleted the bugfix-stage1-libcxx-nanvix-platform branch June 30, 2026 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant